package com.immediatus.util;


public abstract class PoolItem{

    Pool<? extends PoolItem> _Parent;
    boolean _Recycled = true;

    public Pool<? extends PoolItem> getParent(){
        return this._Parent;
    }

    public boolean isRecycled(){
        return this._Recycled;
    }

    public boolean isFromPool(final Pool<? extends PoolItem> pool_){
        return pool_ == this._Parent;
    }

    protected void onRecycle(){
    }

    protected void onObtain(){
    }

    public void recycle(){
        if (this._Parent == null){
            throw new IllegalStateException("Item already recycled!");
        }
        this._Parent.recycle(this);
    }

}